//
//  NSString+SEGSecurity.m
//  SEGBasic
//
//  Created by Clavis on 2019/5/28.
//  Copyright © 2019 刘山. All rights reserved.
//

#import "NSString+SEGSecurity.h"
#import <CommonCrypto/CommonDigest.h> // Need to import for CC_MD5 access

@implementation NSString (SEGSecurity)

/**
 md5 32位 小写加密
 
 @param str - 原字符串
 @return - 加密后的字符串
 */
+(NSString*)seg_md532BitLower:(NSString *)str {
    const char *cStr = [str UTF8String];
    unsigned char result[16];
    
    NSNumber *num = [NSNumber numberWithUnsignedLong:strlen(cStr)];
    CC_MD5( cStr,[num intValue], result );
    
    return [[NSString stringWithFormat:
             @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
             result[0], result[1], result[2], result[3],
             result[4], result[5], result[6], result[7],
             result[8], result[9], result[10], result[11],
             result[12], result[13], result[14], result[15]
             ] lowercaseString];
}

@end
